package com.duoduo.homework.h1;

import com.duoduo.algs4.util.ArrayUtil;

import edu.princeton.cs.introcs.StdOut;
import edu.princeton.cs.introcs.StdRandom;

public class ShuffleTest {

	private int[] array;
	private int[][] T;

	private void init() {
		int M = array.length;
		for (int i = 0; i < M; i++) {
			array[i] = i;
		}
	}

	private void test(int M, int N) throws Exception {
		array = new int[M];
		T = new int[M][M];
		for (int i = 0; i < N; i++) {
			init();
			StdRandom.shuffle(array);
			//ArrayUtil.printArray(array);
			for (int j = 0; j < M; j++) {
				T[j][array[j]]++;
			}
		}
		StdOut.println("N/M :" + 1.0 * N / M);
		ArrayUtil.printDoubleArray(T);
	}

	public static void main(String[] args) throws Exception {
		new ShuffleTest().test(10,10000000);

	}

}
